package com.dzxcqmxm.servlet.photo;

import com.dzxcqmxm.Dao.AlbumDao;
import com.dzxcqmxm.Dao.PhotoDao;
import com.dzxcqmxm.Dao.impl.AlbumDaoImpl;
import com.dzxcqmxm.Dao.impl.PhotoDaoImpl;
import com.dzxcqmxm.JB.Album;
import com.dzxcqmxm.JB.Photo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Payboi
 * @create 2022/6/4-19:35
 * @FileName updatePhotoServlet
 * @Description
 */
@WebServlet("/updatePhotoServlet")
public class updatePhotoServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PhotoDao photoDao = new PhotoDaoImpl();
        Photo photo = new Photo();

        photo.setPhotoName(new String(request.getParameter("PhotoName" ).getBytes("iso-8859-1"),"UTF-8"));
        photo.setPhotoBaoMi(new String(request.getParameter("PhotoBaomi" ).getBytes("iso-8859-1"),"UTF-8"));

        try {
            /**
             * 执行了更新语句
             */
            photoDao.updatePhoto(photo);
        } catch (Exception e) {
            e.printStackTrace();
        }

        response.sendRedirect("/dzxc/YongHu/yhPhoto/yhDisplayPhoto.jsp");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
